package dry.example.parse;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author zc
 */
public class Demo {

    private final User user = new User();

    public void run01() {
        User u1 = new User();
        u1.setId(1);
        u1.setName("a");
        User u2, u3;
        u2 = new User();
        u3 = new User();
        run02(u1, u1.getId(), u1.getName());
        run02(u2, u2.getId(), u2.getName());
        run02(u3, u3.getId(), u3.getName());
        //
        System.out.println(user);
        System.out.println(user.getId());
        System.out.println(user.getName());
        //
        System.out.println(u1);
        System.out.println(u1.getId());
        System.out.println(u1.getName());
        //
        System.out.println(u2);
        System.out.println(u2.getId());
        System.out.println(u2.getName());
        //
        System.out.println(u3);
        System.out.println(u3.getId());
        System.out.println(u3.getName());
    }

    public void run02(User user, Integer id, String name) {
        int m = 50;
        System.out.println(user);
        System.out.println(id);
        System.out.println(name);
        System.out.println(m);
    }

    public void run02(User user) {
        int m = 10;
        int n = 10;
        System.out.println(user);
        System.out.println(m);
        System.out.println(n);
    }

    public void run03() {
        int x = 1;
        int y = 2, z = 3;
        System.out.println(x);
        System.out.println(y);
        System.out.println(z);
    }

    public void run04() {
        List<String> list = new ArrayList<>();
        list.add("a");
        list.add("b");
        boolean b = true;
        if (b && list.size() >= 0) {
            System.out.println(list);
        }
    }

    public void run05() {
        List<User> list = new ArrayList<>();
        list.add(new User(1, "a"));
        list.add(new User(2, "b"));
        Map<Integer, String> r = list.stream().collect(Collectors.toMap(item -> item.getId() * 2, User::getName, (v1, v2) -> v2));
    }

}
